package com.cellulam.framework.mq;

import com.aliyun.openservices.ons.api.Message;
import com.cellulam.framework.core.utils.JacksonUtils;
import com.cellulam.framework.core.base.ResourceId;
import lombok.Getter;

@Getter
public class MessageFeature<T extends ResourceId> {
    public MessageFeature(String groupId, Message message, T body) {
        this.groupId = groupId;
        this.topic = message.getTopic();
        this.tag = message.getTag();
        this.msgId = message.getMsgID();
        this.msgKey = message.getKey();
        this.body = body;
    }

    /**
     * group ID
     */
    private String groupId;

    /**
     * 队列Topic
     */
    private String topic;

    /**
     * Tag
     */
    private String tag;

    /**
     * 消息ID
     */
    private String msgId;

    /**
     * 消息key
     */
    private String msgKey;

    /**
     * 内容体
     */
    private T body;

    @Override
    public String toString() {
        return String.format("MessageFeature[groupId=%s,topic=%s,tag=%s,msgId=%s,msgKey=%s]",
                this.groupId,
                this.topic,
                this.tag,
                this.msgId,
                this.msgKey,
                JacksonUtils.toJson(body));
    }
}
